//
//  BannerDetailViewController.m
//  HWZB
//
//  Created by 许成雄 on 2017/4/26.
//  Copyright © 2017年 wonders. All rights reserved.
//

#import "BannerDetailViewController.h"
#import <SVProgressHUD/SVProgressHUD.h>

@interface BannerDetailViewController () <UIWebViewDelegate>

@property (strong, nonatomic) UIWebView *webView;

@end

@implementation BannerDetailViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.edgesForExtendedLayout = UIRectEdgeNone;
    self.view.backgroundColor = I_COLOR_WHITE;
    [self setBackNavgationItem];
    self.navigationItem.title = @"活动详情";
    
    [self createUI];
    
    if(self.bannerInfo && self.bannerInfo.wxmpUrl) {
        NSURL *url = [NSURL URLWithString:self.bannerInfo.wxmpUrl];
        [self.webView loadRequest:[NSURLRequest requestWithURL:url]];
    }
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

#pragma mark - UIWebViewDelegate
- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType {
    return true;
}

- (void)webViewDidStartLoad:(UIWebView *)webView {
    [SVProgressHUD showWithStatus:@"加载中, 请稍等..." maskType:SVProgressHUDMaskTypeClear];
}

- (void)webViewDidFinishLoad:(UIWebView *)webView {
//    NSString *str = @"document.getElementsByTagName('body')[0].style.webkitTextSizeAdjust= '90%'";
//    [self.webView stringByEvaluatingJavaScriptFromString:str];
    [SVProgressHUD dismiss];
}

- (void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error {
    [SVProgressHUD dismiss];
}


#pragma mark - Private Method
- (void)createUI {
    self.webView = [[UIWebView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT - 64.0f)];
    self.webView.backgroundColor = [UIColor clearColor];
    self.webView.scrollView.backgroundColor = [UIColor clearColor];
    [self.webView setScalesPageToFit:NO];
    self.webView.scrollView.showsVerticalScrollIndicator = NO;
    [self.view addSubview:self.webView];
    self.webView.delegate = self;
}

- (void)loadData {
    
}

@end
